//
//  SearchTableViewCell.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/13.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "SearchTableViewCell.h"
@interface SearchTableViewCell ()

@property (nonatomic,strong) UIButton * cleanBtn ;
@end
@implementation SearchTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initlizeInterface];
    }
    return self;
}

- (void)initlizeInterface {
    [self.contentView addSubview:self.contextLabel];
    [self.contentView addSubview:self.cleanBtn];
    [self.contextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15*xsIZE);
        make.centerY.equalTo(self.contentView);
        make.width.equalTo(self.contentView).multipliedBy(0.5);
        make.height.offset(20*ysIZE);
    }];
    [self.cleanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-23*xsIZE);
        make.centerY.equalTo(self.contentView);
        make.height.equalTo(self.contextLabel);
        make.width.equalTo(self.cleanBtn.mas_height);
    }];

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}
- (void)cleanButtonAction {
    if (self.SearchDelegate && [self.SearchDelegate conformsToProtocol:@protocol(SearchCleanDelegate)]) {
        [self.SearchDelegate deleteWithBtnindex:_btnIndex];
    }
}



- (UILabel *)contextLabel {
    if (_contextLabel) {
        return _contextLabel;
    }
    _contextLabel = [[UILabel alloc] init];
    _contextLabel.textAlignment = NSTextAlignmentLeft;
    _contextLabel.textColor =  KHColorFromRGB(0x666666);
    return _contextLabel;
}
- (UIButton *)cleanBtn {
    if (_cleanBtn) {
        return _cleanBtn;
    }
    _cleanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cleanBtn setImage:[UIImage imageNamed:@"search_btn_cha"] forState:UIControlStateNormal];
    [_cleanBtn addTarget:self action:@selector(cleanButtonAction) forControlEvents:UIControlEventTouchUpInside];
    return _cleanBtn;
}
@end
